import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton } from '../Common/options'

export const Performances = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [<AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />],
        columns: [
            commonTableList.uuid,
            commonTableList.tableName,
            {
                dataIndex: 'performanceType',
                title: '类型',
                width: 120,
                rules: true,
                ellipsis: true,
                valueType: 'select',
                valueEnum: { 0: '施工单位', 1: '设计单位', 2: '监理单位', 3: '试验室' },
            },
            {
                dataIndex: 'score',
                title: '分数',
                valueType: 'input',
                ellipsis: true,
                hideInSearch: true,
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'yearMonth',
                title: '年月',
                valueType: 'Date',
                picker: 'month',
                ellipsis: true,
                rules: true,
                width: 150,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 400,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
